﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using ServiceStack;
using System;
using XuanXiang.Api.Admin.Filters;
using XuanXiang.Infrastructure.Attr;
using XuanXiang.Infrastructure.Dto.Request;
using XuanXiang.Infrastructure.Dto.Request.Goods;
using XuanXiang.Infrastructure.Dto.Response.Goods;
using XuanXiang.Infrastructure.EFCore.MySql;
using XuanXiang.Service.Interface;

namespace XuanXiang.Api.Admin.Controllers
{
    [ApiGroup("Admin(管理员模块)")]
    public class HomeController : BaseController
    {
        private readonly I_Home_Service _home_Service;

        public HomeController(I_Login_Service login_Service,I_Home_Service home_Service) : base(login_Service)
        {
            _home_Service = home_Service;
        }

        /// <summary>
        /// 获取首页的数据统计
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetHomeStatistics() {
            var result = await _home_Service.GetHomeStatistics();
            return Ok(result);
        }

        /// <summary>
        /// 获取首页统计图数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_Home_Cartogram() {
            var result = await _home_Service.Get_Home_Cartogram();
            return Ok(result);
        }

        /// <summary>
        /// 获取销售额top10的供应商
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_Top_Supplier() {
            var result = await _home_Service.Get_Top_Supplier();
            return Ok(result);
        
        }

        /// <summary>
        /// 获取采购量top10的商户
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_Top_Merchant() {
            var result = await _home_Service.Get_Top_Merchant();
            return Ok(result);
        }


        /// <summary>
        /// 获取热销top5的商品
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_Top_Goods() {
            var result = await _home_Service.Get_Top_Goods();
            return Ok(result);
        }
    }
}
